//
//  SinaRefreshView.swift
//  weibo
//
//  Created by sirius on 16/1/8.
//  Copyright © 2016年 sirius. All rights reserved.
//

import UIKit

class SinaRefreshView: UIView {
    
    
    @IBOutlet weak var pullImageView: UIImageView!
    
    @IBOutlet weak var pullView: UIView!
    
    
    
    @IBOutlet weak var loadingImageView: UIImageView!
    
    //添加动画
    func loadingAnimation(){
         
        //创建一个基本动画
        let animation = CABasicAnimation(keyPath:"transform.rotation")
        
        //设置属性
        animation.toValue = 2 * M_PI
        animation.duration = 2
        
        animation.repeatCount = MAXFLOAT
        animation.removedOnCompletion = false
        //添加到layer
        loadingImageView.layer.addAnimation(animation, forKey: nil)
        
    }
    //移除所有的动画z
    func removeAnimation(){
        loadingImageView.layer.removeAllAnimations()
    }
    //下拉刷新的动画
    func startTurn(){
        //注意转动角度
        UIView.animateWithDuration(1) { () -> Void in
             self.pullImageView.transform = CGAffineTransformRotate(self.pullImageView.transform, CGFloat(M_PI))
        }
    }


}
